//
//  KYCheckInPrizeModel.m
//  KYCheckInSDK
//
//  Created by 罗新 on 2017/11/3.
//  Copyright © 2017年 KuaiYan  Co.,LTD. All rights reserved.
//

#import "KYCheckInPrizeModel.h"
#import "KYCheckInPrizeDetialModel.h"
@implementation KYCheckInPrizeModel
+ (instancetype)checkInPrizeModelWithDict:(NSDictionary *)dict modelIndex:(NSInteger)index{
    KYCheckInPrizeModel *model = [[KYCheckInPrizeModel alloc] init];
    model.tubiaoImg = dict[@"tubiaoImg"];
    model.tubiaoTitle = dict[@"tubiaoTitle"];
    model.modelIndex = [NSString stringWithFormat:@"%ld",index];
    model.sort = dict[@"sort"];
    if (!IsDictEmpty(dict[@"data"])) {
        model.prizeDatialModel = [KYCheckInPrizeDetialModel checkInPrizeDetialModelWithDict:dict[@"data"]];
    }
    return model;
}
// 自定义排序方法
- (NSComparisonResult)compareParkInfo:(KYCheckInPrizeModel *)parkinfo{
    // 升序
    NSComparisonResult result = [[NSNumber numberWithInteger:self.sort.integerValue] compare:[NSNumber numberWithInteger:parkinfo.sort.integerValue]];
    if (result == NSOrderedSame) {
        // 可以按照其他属性进行排序
    }
    return result;
}
- (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:self.tubiaoImg forKey:@"tubiaoImg"];
    [aCoder encodeObject:self.tubiaoTitle forKey:@"tubiaoTitle"];
    [aCoder encodeObject:self.modelIndex forKey:@"modelIndex"];
    [aCoder encodeObject:self.sort forKey:@"sort"];
    [aCoder encodeObject:self.prizeDatialModel forKey:@"prizeDatialModel"];
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self.tubiaoImg = [aDecoder decodeObjectForKey:@"tubiaoImg"];
    self.tubiaoTitle = [aDecoder decodeObjectForKey:@"tubiaoTitle"];
    self.modelIndex = [aDecoder decodeObjectForKey:@"modelIndex"];
    self.sort = [aDecoder decodeObjectForKey:@"sort"];
    self.prizeDatialModel = [aDecoder decodeObjectForKey:@"prizeDatialModel"];
    return self;
}
@end
